package com.lxmes.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.pm.domain.ARewardInfo;
import com.lxmes.pm.service.IARewardInfoService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 成果奖励Controller
 * 
 * @author zhangzhiyu
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/pm/rewardInfo")
public class ARewardInfoController extends BaseController
{
    @Autowired
    private IARewardInfoService aRewardInfoService;

    /**
     * 查询成果奖励列表
     */
    @PreAuthorize("@ss.hasPermi('pm:rewardInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ARewardInfo aRewardInfo)
    {
        startPage();
        List<ARewardInfo> list = aRewardInfoService.selectARewardInfoList(aRewardInfo);
        return getDataTable(list);
    }

    /**
     * 导出成果奖励列表
     */
    @PreAuthorize("@ss.hasPermi('pm:rewardInfo:export')")
    @Log(title = "成果奖励", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ARewardInfo aRewardInfo)
    {
        List<ARewardInfo> list = aRewardInfoService.selectARewardInfoList(aRewardInfo);
        ExcelUtil<ARewardInfo> util = new ExcelUtil<ARewardInfo>(ARewardInfo.class);
        util.exportExcel(response, list, "成果奖励数据");
    }

    /**
     * 获取成果奖励详细信息
     */
    @PreAuthorize("@ss.hasPermi('pm:rewardInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aRewardInfoService.selectARewardInfoById(id));
    }

    /**
     * 新增成果奖励
     */
    @PreAuthorize("@ss.hasPermi('pm:rewardInfo:add')")
    @Log(title = "成果奖励", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ARewardInfo aRewardInfo)
    {
        return toAjax(aRewardInfoService.insertARewardInfo(aRewardInfo));
    }

    /**
     * 修改成果奖励
     */
    @PreAuthorize("@ss.hasPermi('pm:rewardInfo:edit')")
    @Log(title = "成果奖励", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ARewardInfo aRewardInfo)
    {
        return toAjax(aRewardInfoService.updateARewardInfo(aRewardInfo));
    }

    /**
     * 删除成果奖励
     */
    @PreAuthorize("@ss.hasPermi('pm:rewardInfo:remove')")
    @Log(title = "成果奖励", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aRewardInfoService.deleteARewardInfoByIds(ids));
    }
}
